﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;

namespace ueEngine.Biz.Inf.Entities
{
    /// <summary>
    /// 系统公告
    /// </summary>
    [Table("SystemNotice")]
    public class SystemNotice : BaseEntity<SystemNotice>
    {
        public override SystemNotice Get(System.Linq.Expressions.Expression<Func<SystemNotice, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.SystemNotice.FirstOrDefault(where);
                if (item != null)
                {
                    this.Content = item.Content;
                    this.Editor = item.Editor;
                    this.Id = item.Id;
                    this.PublishDate = item.PublishDate;
                    this.Subject = item.Subject;
                    this.Title = item.Title;
                    this.Type = item.Type;
                    return this;
                }
                return null;
            }
        }
        #region Fileds
        [Key]
        [Column("Id",TypeName="int")]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 公告标题
        /// </summary>
        [Column("Title",TypeName="nvarchar")]
        [StringLength(200)]
        public string Title { get; set; }

        /// <summary>
        /// 公告编辑
        /// </summary>
        [Column("Editor",TypeName="varchar")]
        [StringLength(200)]
        public string Editor { get; set; }
        
        /// <summary>
        /// 公告内容
        /// </summary>
        [Column("Content",TypeName="nvarchar")]
        [StringLength(2000)]
        public string Content { get; set; }

        /// <summary>
        /// 公告分类
        /// </summary>
        [Column("Type", TypeName="int")]
        public int Type { get; set; }

        /// <summary>
        /// 公告子类
        /// </summary>
        [Column("Subject",TypeName="int")]
        public int Subject { get; set; }

        /// <summary>
        /// 发布日期
        /// </summary>
        [Column("PublishDate",TypeName="datetime")]
        public DateTime PublishDate { get; set; }
        #endregion
    }
}
